package com.zsx.shopping.common.exception;

import com.zsx.shopping.common.enums.CodeMsg;
import lombok.Getter;

@Getter
public class ShoppingException extends RuntimeException {

    private Integer code;

    private String msg;

    // 默认异常,前端静默
    public ShoppingException() {
        CodeMsg fail = CodeMsg.FAIL;
        code = fail.getCode();
        msg = fail.getMsg();
    }

    // 指定消息,前端将会提示该消息
    public ShoppingException(String msg) {
        this.code = CodeMsg.FAIL.getCode();
        this.msg = msg;
    }

    // 指定响应码及消息,前端根据响应码做出特定动作及提示消息
    public ShoppingException(Integer code, String msg) {
        this.code = code;
        this.msg = msg;
    }
}
